/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ylystudio.pms.ejb.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "risk_category")
@NamedQueries({
    @NamedQuery(name = "RiskCategory.findAll", query = "SELECT r FROM RiskCategory r"),
    @NamedQuery(name = "RiskCategory.findByRcId", query = "SELECT r FROM RiskCategory r WHERE r.rcId = :rcId"),
    @NamedQuery(name = "RiskCategory.findByRcName", query = "SELECT r FROM RiskCategory r WHERE r.rcName = :rcName"),
    @NamedQuery(name = "RiskCategory.findByRcLevel", query = "SELECT r FROM RiskCategory r WHERE r.rcLevel = :rcLevel")})
public class RiskCategory implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "rc_id")
    private Integer rcId;
    @Basic(optional = false)
    @Column(name = "rc_name")
    private String rcName;
    @Basic(optional = false)
    @Column(name = "rc_level")
    private int rcLevel;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "riskCategory", fetch = FetchType.LAZY)
    private List<RiskItem> riskItemList;
    @JoinColumn(name = "project_id", referencedColumnName = "p_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Project project;

    public RiskCategory() {
    }

    public RiskCategory(Integer rcId) {
        this.rcId = rcId;
    }

    public RiskCategory(Integer rcId, String rcName, int rcLevel) {
        this.rcId = rcId;
        this.rcName = rcName;
        this.rcLevel = rcLevel;
    }

    public Integer getRcId() {
        return rcId;
    }

    public void setRcId(Integer rcId) {
        this.rcId = rcId;
    }

    public String getRcName() {
        return rcName;
    }

    public void setRcName(String rcName) {
        this.rcName = rcName;
    }

    public int getRcLevel() {
        return rcLevel;
    }

    public void setRcLevel(int rcLevel) {
        this.rcLevel = rcLevel;
    }

    public List<RiskItem> getRiskItemList() {
        return riskItemList;
    }

    public void setRiskItemList(List<RiskItem> riskItemList) {
        this.riskItemList = riskItemList;
    }

    public Project getProject() {
        return project;
    }

    public void setProject(Project project) {
        this.project = project;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (rcId != null ? rcId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RiskCategory)) {
            return false;
        }
        RiskCategory other = (RiskCategory) object;
        if ((this.rcId == null && other.rcId != null) || (this.rcId != null && !this.rcId.equals(other.rcId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ylystudio.pms.ejb.entity.RiskCategory[rcId=" + rcId + "]";
    }

}
